Skip to content

Conversation

OddExtension5
Copy link
Contributor

No description provided.

@OddExtension5
Copy link
Contributor Author

@cclauss Your review, please.

Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put these into data_structures/hashes?

The overlap in the three open PRs is making reviews difficult. Let's close or land some of them.

# 2. Take n = ra*by + rb*ax

# import testmod for testing our function
from doctest import testmod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this line down just below line 68...
We do not need this import when we run your functions, only when we test them.

return (n % m + m) % m


if __name__ == '__main__':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from doctest import testmod

@@ -0,0 +1,70 @@
# Chinese Remainder Theorem:

# If GCD(a,b) = 1, then for any remainder ra modulo a and any remainder rb modulo b there exists integer n,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please expand the acronym GCD and try to keep the lines to 88 characters or less.


# This function find the inverses of a i.e., a^(-1)
def invert_modulo(a, n):
(b, x) = extended_euclid(a, n)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No doctest?


# Euclid's Algorithm

def gcd(a, b):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please expand the acronym gcd

# Uses ExtendedEuclid to find the inverse of a

# Import testmod for testing our function
from doctest import testmod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move down to main()

@OddExtension5 OddExtension5 changed the title Efficient Modular Division Algorithm Chinese Remainder Theorem | Diophantine Equation | Modular Division Oct 2, 2019
@OddExtension5
Copy link
Contributor Author

All Done! @cclauss @cozek

@OddExtension5 OddExtension5 requested a review from cclauss October 2, 2019 14:28
@cclauss
Copy link
Member

cclauss commented Oct 3, 2019

OK...

  1. Please close Diophantine Equation #1236 and added chinese_remainder_theorem #1232 with a message Closing in favor of Chinese Remainder Theorem | Diophantine Equation | Modular Division #1248
  2. Please change the path for these files from data_structures/hashing/number_theory to blockchain as discussed at Diophantine Equation #1236 (comment).

This was referenced Oct 3, 2019
@OddExtension5
Copy link
Contributor Author

Done..

Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!

@cclauss cclauss merged commit 9cc9f67 into TheAlgorithms:master Oct 6, 2019
@OddExtension5 OddExtension5 deleted the modular_division branch December 7, 2019 14:40
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
…heAlgorithms#1248)

* Update .gitignore to remove __pycache__/

* added chinese_remainder_theorem

* Added Diophantine_equation algorithm

* Update Diophantine eqn & chinese remainder theorem

* Update Diophantine eqn & chinese remainder theorem

* added efficient modular division algorithm

* added GCD function

* update chinese_remainder_theorem | dipohantine eqn | modular_division

* update chinese_remainder_theorem | dipohantine eqn | modular_division

* added a new directory named blockchain & a files from data_structures/hashing/number_theory

* added a new directory named blockchain & a files from data_structures/hashing/number_theory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants